﻿using System.Collections.Generic;
using UnityEngine;
using Verse;
using RimWorld;

namespace RimZombieGirl
{
    public class GameCondition_CursedBloodFog : GameCondition
    {
        //private WeatherOverlay_BloodFog bloodFogOverlay;
        private WeatherOverlay_PaperCoinRain paperCoinOverlay;

        private static readonly SkyColorSet ScarletHazeColors =
            new SkyColorSet(new ColorInt(255, 60, 60).ToColor,   // 主天色：深红
                            new ColorInt(180, 30, 30).ToColor,   // 辅助光：暗红
                            new ColorInt(255, 100, 100).ToColor, // 环境光：绯红
                            0.45f);

        private List<SkyOverlay> overlays = new List<SkyOverlay>
        {
            new WeatherOverlay_Fog(),// 可以自定义 overlay，或者直接 Fog 效果
            new WeatherOverlay_PaperCoinRain()
        };
        public override SkyTarget? SkyTarget(Map map)
        {
            return new SkyTarget(0.45f, ScarletHazeColors, 1f, 1f);
        }

        public override float SkyTargetLerpFactor(Map map)
        {
            return GameConditionUtility.LerpInOutValue(this, 3000, 0.5f);
        }

        public override List<SkyOverlay> SkyOverlays(Map map) => overlays;

        public override void Init()
        {
            base.Init();
            //bloodFogOverlay = new WeatherOverlay_BloodFog();
            paperCoinOverlay = new WeatherOverlay_PaperCoinRain();
        }

        public override void GameConditionTick()
        {
            base.GameConditionTick();
            // 不做额外tick逻辑，主要是温度调控
            //bloodFogOverlay.TickOverlay(SingleMap,0.2f);
            paperCoinOverlay.TickOverlay(SingleMap,0.2f);

        }
        public override int TransitionTicks
        {
            get
            {
                return 48000;
            }
        }

        // Token: 0x0600A7D4 RID: 42964 RVA: 0x00301CF3 File Offset: 0x002FFEF3
        public override float TemperatureOffset()
        {
            return GameConditionUtility.LerpInOutValue(this, (float)this.TransitionTicks, -100f);
        }

        public override void GameConditionDraw(Map map)
        {
            base.GameConditionDraw(map);
            if (map == SingleMap)
            {
                //bloodFogOverlay.DrawOverlay(map);
                // 纸钱雨覆盖
                paperCoinOverlay.DrawOverlay(map);
            }
        }

        public override void ExposeData()
        {
            base.ExposeData();
            // 保存/加载 overlay
        }
    }
}
